package com.lastcrdg.testrecycleview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = MainActivity.class.getSimpleName();
    private RecyclerView rv;
    private List<String> datas;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rv = (RecyclerView) findViewById(R.id.rv);
        initData();
        init();
    }

    private void init() {
        rv.setLayoutManager(new LinearLayoutManager(this));
        RvAdapter adapter = new RvAdapter(datas);
        rv.setAdapter(adapter);
        Log.d(TAG, "init: " + adapter.getItemCount());
    }

    private void initData() {
        datas = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            String data = i + "data" + i;
            datas.add(data);
        }
    }
    
}
